﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace WeixinSB.Converter
{
    public class BoolToVisility : IValueConverter
    {


        public object Convert(object value, Type targetType, object parameter, string language)
        {

            if (value == null)
            {
                return Visibility.Collapsed;
            }
            var b = false;
            bool.TryParse(value.ToString(), out b);
            if (b)
            {
                return Visibility.Visible;
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }


    public class BoolToOpacity : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {

            if (value == null)
            {
                return 0;
            }
            var b = false;
            bool.TryParse(value.ToString(), out b);
            if (b)
            {
                return 1;
            }

            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
